'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db = uniCloud.database({});
	const shop = db.collection('db_user')
	//返回数据给客户端
	let len = 0
	await shop.where({
		acc: event.acc
	}).get().then((con) => {
		len = con.data.length
		console.log(con.data.length, 56565)

	})
	if (len == 0) {

		await shop.add({
			uname: event.uname,
			acc: event.acc,
			pwd: event.pwd,
			sig: event.sig || "天青色等烟雨",
			addr: "未填写",
			addrDetail: "未填写"
		});
		return {
			msg: "用户注册成功",
			code: 200,
		}
	} else {
		return {
			msg: "该账号已注册",
			code: 201
		}
	}

}